package com.spzx.product.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.spzx.common.core.domain.R;
import com.spzx.common.security.annotation.InnerAuth;
import com.spzx.product.api.domin.ProductSku;
import com.spzx.product.service.ProductSkuService;
import com.spzx.product.vo.SkuPriceVo;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.spzx.common.core.web.controller.BaseController;

import java.util.List;


@RestController
@RequestMapping("/productSku")
public class ProductSkuController extends BaseController {

    @Autowired
    private ProductSkuService productSkuService;

    @InnerAuth
    @Operation(summary = "获取商品SKU详情")
    @GetMapping("/getProductSku/{skuId}")
    public R<ProductSku> getProductSku(@PathVariable("skuId") Long skuId) {
        ProductSku productSku = productSkuService.getById(skuId);
        return R.ok(productSku);
    }

    @InnerAuth
    @Operation(summary = "批量获取商品sku最新价格信息")
    @PostMapping("getSkuPriceList")
    public R<List<SkuPriceVo>> getskupricelist(@RequestBody List<Long> skuIds){
        return R.ok(productSkuService.getskupricelist(skuIds));
    }

    @InnerAuth
    @Operation(summary = "获取单个商品sku最新价格信息")
    @GetMapping(value = "/getSkuPrice/{skuId}")
    public R<SkuPriceVo> getSkuPrice(@PathVariable("skuId") Long skuId)
    {
        return R.ok(productSkuService.getskuprice(skuId));
    }
}